home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Frameworks
/
Extension Shell 1.5
/
Sample Extensions (1.5)
/
Bell Test ƒ
/
PlaySound.c
< prev
Wrap
C/C++ Source or Header
|
1995-11-01
|
2KB
|
119 lines
/* NAME:
PlaySound.c
WRITTEN BY:
Dair Grant
DESCRIPTION:
This file contains a Code resource to be installed as a code block in
the System Heap.
NOTES:
When we are called, we play the sound handle contained in the address
table.
___________________________________________________________________________
*/
#include <Gestalt.h>
#include <Sound.h>
#include "A4Stuff.h"
#include "SetupA4.h"
#include "BT Constants.h"
#include "BT AddrsTable.h"
//=============================================================================
// Global Variables
//-----------------------------------------------------------------------------
Handle gTheSoundToPlay;
Boolean gAlreadyRan = false;
//=============================================================================
// Private function prototypes
//-----------------------------------------------------------------------------
pascal void main(void);
//=============================================================================
// main : Entry point to our code resource.
//-----------------------------------------------------------------------------
// Note : We get hold of the handle to the sound from our address table,
// and play it.
//-----------------------------------------------------------------------------
pascal void main(void)
{ long oldA4;
OSErr theErr;
BTAddressTable *theAddressTable;
// Set up A4
#ifndef powerc
oldA4 = SetCurrentA4();
#endif
// If we've not already been called, do our one time initialisation stuff
if (!gAlreadyRan)
{
Gestalt(kBellTestAddressTable, (long *) &theAddressTable);
gTheSoundToPlay = theAddressTable->theSound;
gAlreadyRan = true;
}
// Play the sound
if (gTheSoundToPlay)
theErr = SndPlay(nil, (SndListHandle) gTheSoundToPlay, true);
// Restore A4 and return
#ifndef powerc
SetA4(oldA4);
#endif
}